#include "bmp.c"
#include "Image.h"
#include "Scene.h"
#include "Observateur.h"
#include "Point.h"
#include "Sphere.h"
#include "Phong.h"
#include "Plan.h"
#include <stdio.h>
#include <math.h>

int main(int argc, char *argv[], char *env[]) {

	int tailleImage = 200;
	
	char * imageNom = new char[250];

	
	Image * image = new Image(tailleImage,tailleImage,"monImage.bmp");
	Point * origineVue = new Point(0.0,10.0,10.0);
	Point * destinationVue = new Point(0.0,0.0,0.0);
	Observateur * observateur = new Observateur(*origineVue, *destinationVue,45.0,tailleImage);

	Couleur * couleurFond = new Couleur(0,0,0);
	Scene * scene = new Scene(*observateur,*image,*couleurFond);

	Sphere * sphere = new Sphere(2.0, Point(0.0, 3.0, 0.0));
	sphere->setIllum(new Phong(1.0, 0.5, Couleur(1, 0, 0), Couleur(1, 1, 1), 100));
	//sphere->setCouleur(Couleur(1,0,0));

	Sphere * sphere2 = new Sphere(2.0, Point(2.0, 3.0, 0.0));
	sphere2->setIllum(new Phong(0.5, 0.5, Couleur(0, 1, 0), Couleur(1, 1, 1), 50));
	//sphere2->setCouleur(Couleur(0,1,0));

	Plan * plan = new Plan (0, 1, 0, 0);
	plan->setCouleur(Couleur(0,0,1));
	// Probleme avec n de phong
	plan->setIllum(new Phong(0.5, 0.5, Couleur(0, 0, 1), Couleur(1, 1, 1), 20000000));

	scene->ajouterObjet(plan);
	scene->ajouterObjet(sphere);
	scene->ajouterObjet(sphere2);

	Point * sourceLumiere = new Point(0,10,4);

	int i=0;
	//for(i = 0; i < 180; i+=5){
		scene->setNbLumiere(0);
		sprintf(imageNom,"image/monImage%d.bmp",i);
		BMPImage * monImage = Create_Image(imageNom,tailleImage,tailleImage);
		Point sL2 = *sourceLumiere * Matrice::creerRotation((i*3.1415/180),Vecteur::axeY);
		Lumiere * lumiere = new Lumiere(sL2, Couleur(1, 1, 1));
		scene->ajouterLumiere(lumiere);
	
		scene->rayTrace();

		monImage->pic = image->getPic();
		WriteBitmap(imageNom,monImage);
	//}




	return 0;
}
